<template>
	<!-- 新增课程类型 -->
	<div class="weui-panel" style="height: 100%; width: 100%;">
		<div class="weui-cell">
			<button class="backBtn" @click="goBack">返回</button>
		</div>
		<div class="weui-cells__group weui-cells__group_form" style="height: 100%;width: 100%;">
			<div class="weui-cells__title" style="margin-top: 0.625rem;">课程类型</div>
			<div class="weui-cells weui-cells_form" style="height: 80%;width: 100%; overflow: auto;">
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">课程类型名</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.caseTypeName" class="weui-input" placeholder="课程类型名">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">课程类型编号</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.caseType" class="weui-input" placeholder="课程类型编号">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">课程购买初始基数</label></div>
					<div class="weui-cell__bd">
						<input type="number" v-model="caseTypeInfo.caseFirstBuyCount" class="weui-input" placeholder="课程购买初始基数">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">每一次购买增加课时</label></div>
					<div class="weui-cell__bd">
						<input type="number" v-model="caseTypeInfo.caseBuyIncreaseCount" class="weui-input"
							placeholder="每一次购买增加课时">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">课程单价</label></div>
					<div class="weui-cell__bd">
						<input type="number" v-model="caseTypeInfo.caseSale" class="weui-input" value="售价" />
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">课程促销价</label></div>
					<div class="weui-cell__bd">
						<input type="number" v-model="caseTypeInfo.caseSaleDz" class="weui-input" value="售价" />
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">一次购买达到10节优惠（元）</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.buyTenCount1" class="weui-input"
						 placeholder="优惠多少元">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">一次购买达到20节优惠（元）</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.buyTenCount2" class="weui-input" placeholder="优惠多少元">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">一次购买达到30节优惠（元）</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.buyTenCount3" class="weui-input" placeholder="优惠多少元">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">一次购买达到40节优惠（元）</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.buyTenCount4" class="weui-input" placeholder="优惠多少元">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">一次购买达到50节优惠（元）</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.buyTenCount5" class="weui-input" placeholder="优惠多少元">
					</div>
				</div>
				<div class="weui-cell ">
					<div class="weui-cell__hd"><label class="weui-label">一次购买达到50节以上优惠（元）</label></div>
					<div class="weui-cell__bd">
						<input v-model="caseTypeInfo.buyTenCount6" class="weui-input" placeholder="优惠多少元">
					</div>
				</div>
				<div class="weui-cell weui-cell_switch">
					<div class="weui-cell__bd">是否启用类型</div>
					<div class="weui-cell__ft">
						<label for="switchCP" class="weui-switch-cp">
							<input id="switchCP" class="weui-switch-cp__input"
								v-model="caseTypeInfo.status == 0?true:false" type="checkbox" checked="checked">
							<div class="weui-switch-cp__box"></div>
						</label>
					</div>
				</div>
				<div>
					<button @click="addCaseType" class="btn">保存</button>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import uwLoadJs from '@/utils/uwLoad'
	import constant from '@/utils/constant'
	import apis from '@/utils/apis'
	import {
		saveCaseType
	} from '@/apis/tech/tech.js'

	import {
		showMsg
	} from '@/apis/common/common.js'
	export default {
		inject: ['reload'],
		data() {
			return {
				caseTypeInfo:{}//
				
			}
		},
		created() {
			debugger
			let urlParams = this.$route.params;
			if(urlParams !=undefined && JSON.stringify(urlParams) !="{}") {
				this.caseTypeInfo = urlParams['caseType'];
			}
		},
		methods: {

			addCaseType() {
				this.$showLoading({
					showLoadingToastFlag: true,
				});
				let status = this.caseTypeInfo.status;
				if (status == false) {
					this.caseTypeInfo.status = 1;
				} else {
					this.caseTypeInfo.status = 0;
				}
				saveCaseType(apis.saveCaseType, this.caseTypeInfo).then(res => {
					if (res.resultCode == constant.SUCCESS) {
						showMsg(this, res.resultMsg, null, "success")
					} else {
						showMsg(this, res.resultMsg, null, "danger")
					}
					this.$hideLoading();
					this.$router.go(-1);
				}).catch(err => {
					this.$hideLoading();
				})
			},

			goBack() {
				this.$router.go(-1);
			},
		},
		destroyed() {}
	}
</script>

<style>
	@import "../../assets/css/returnBtn.css";

	.backBtn {
		width: 3.125rem;
		display: block;
		text-align: center;
		line-height: 100%;
		padding: 0.3em;
		font: 16px Arial, sans-serif bold;
		font-style: normal;
		text-decoration: none;
		margin: 2px;
		vertical-align: text-bottom;
		zoom: 1;
		outline: none;
		font-size-adjust: none;
		font-stretch: normal;
		border-radius: 50px;
		box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.2);
		text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.3);
		color: #fefee9;
		border: 0.2px solid #2299ff;
		background-repeat: repeat;
		background-size: auto;
		background-origin: padding-box;
		background-clip: padding-box;
		background-color: #3399ff;
		background: linear-gradient(to bottom, #eeeff9 0%, #3399ff 100%);
	}
</style>
